package wiki.kaizen.cloud.security.session.support.realm;

import lombok.Setter;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import wiki.kaizen.cloud.security.session.support.service.RealmService;

/**
 * 身份验证与授权
 *
 * */
public class IAuthorizingRealm extends AuthorizingRealm {

    @Setter
    private RealmService realmService;

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        return realmService.doGetAuthorizationInfo(principals);
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
        return realmService.doGetAuthenticationInfo(token,getName());
    }


}
